package C_Paper;

import java.util.Arrays;
import java.util.Scanner;

public class C100_12 {
    //机器人搬砖
    public static void main(String[] args) {
        bz(new int[]{30,12,25,8,19,23});
        System.out.println("====");
        bz(new int[]{30,12,25,8,19});
    }
    public static void bz(int[] x){
        if (x.length > 8) {
            System.out.println(-1);
            return;
        }
        Arrays.sort(x);
        if (x.length == 8){
            System.out.println(x[7]);
        }
        int sum = 0;
        for (int i : x) {
            sum += i;
        }
        System.out.println(sum = sum/8);
        int times = 8;
        while(true) {
            for (int i : x) {
                int i1 = i % sum == 0 ? i / sum : i / sum + 1;
                times -= i1;
            }
            if (times == 0){
                System.out.println(sum);
                return;
            }
            sum++;
            times = 8;
        }
    }
}
